/******************************************************************************/
//	InputManager.h	-	provides input functionality for the keyboard & mouse
//
//	Author:		Russell Klinkerman
//	Created:	12.06.2004
/******************************************************************************/

#ifndef _INPUTMANAGER_H_
#define _INPUTMANAGER_H_

// DirectInput
#define DIRECTINPUT_VERSION 0x0800
#include "dinput.h"
#pragma comment	(lib, "dinput8.lib"	)
#pragma comment	(lib, "dxguid.lib"	)		// Contains DirectX GUIDs

// Defines/Macros
#define KEYBOARD_IMMEDIATE_SIZE 256
#define KEYBOARD_BUFFERED_SIZE	10

// Classes
class	CInputManager
{
	private:

		// DirectInput General
		LPDIRECTINPUT8			pInputInterface;

		// DirectInput Keyboard
		LPDIRECTINPUTDEVICE8	pKeyboardDevice;
		char					diImmediateKeyboardData[KEYBOARD_IMMEDIATE_SIZE];

		unsigned int			uiBufferedKeyboardSize;
		DIDEVICEOBJECTDATA		diBufferedKeyboardData[KEYBOARD_BUFFERED_SIZE];

		// DirectInput Mouse
		LPDIRECTINPUTDEVICE8	pMouseDevice;
		DIMOUSESTATE2			diMouseState;

		// Application
		HWND	hAppWnd;

	public:

		// contructor
		CInputManager(){}

		// destructor
		~CInputManager(){}

		// Keyboard Specific
		bool	ProcessKeyboard();
		bool	IsKeyDown(int _dxKeyCode);
		bool	IsKeyDownBuffered(int _dxKeyCode);

		// Mouse Specific
		bool	ProcessMouse();
		bool	IsMouseDown(int nMouseButton);
		void	GetMouseDelta(int &_nDeltaX, int &_nDeltaY, int &_nDeltaZ);

		/******************************************************************************/
		//	Init	-	Initializes Input Manager
		//
		//	In:
		//	Out:
		//	Return:	TRUE if successful
		/******************************************************************************/
		bool	Init();

		/******************************************************************************/
		//	Init	-	Shuts down Input Manager
		//
		//	In:
		//	Out:
		//	Return:	TRUE if successful
		/******************************************************************************/
		bool	Shutdown();
};

extern CInputManager inputManager;

#endif